_stats = PLAYER.profile.getInfo('stats');
stats = {
	'block':parseInt(_stats.block.base),
	'charisma':parseInt(_stats.charisma.base),
	'dexterity':parseInt(_stats.dexterity.base),
	'endurance':parseInt(_stats.endurance.base),
	'power':parseInt(_stats.power.base)
};
function search_ok(r){
		console.group('FIGHT');
		console.log('ID:',r.user.user_id);
		console.log('==WIN STAT==');
		console.log("%d%s",Math.round(r.user.stat.fight_wins/r.user.stat.fight_total*100),'%');
		console.log('==user stats==');
		console.log("%d/%d/%d/%d/%d",r.user.stats.block.all,r.user.stats.charisma.all,r.user.stats.dexterity.all,
			r.user.stats.endurance.all,r.user.stats.power.all);
		
		u = r.user.stats;
		can_attack = (u.block.all < stats.block) &&
					(u.charisma.all < stats.charisma) &&
					(u.dexterity.all < stats.dexterity) &&
					(u.power.all < stats.power)		;
		console.log("Can attack :", can_attack?"true":"false");
		if (can_attack){
			console.warn('ATTACKING : ',r.user.user_id);
			API.call('fight.doAttack',{'enemy_id':r.user.user_id},function(r){console.warn('Fight info');console.log(r);ACTIONS.fight.screenLog(r.log_id);},function(r){console.error('Fight info');console.log(r);});
		}else{
			console.warn('New search');
			setTimeout(search, 2000);
		}
		console.groupEnd();
};
function search(){
	search_data = {
		'search'	: {
			'base'	: 2
		},
		'type'		: 'standart'
	};
	API.call('fight.search',search_data,search_ok,function(r){console.error('SEARCH_ERROR');console.error(r)});
}